﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Study.cs" company="ELEN 7045 GROUP II">
//   Contributed by E.Vosloo
// </copyright>
// <summary>
//   The Study class of the StudyDefinition entity module.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Domain.StudyDefinition.Entities
{
    #region

    using System;
    using System.Collections.ObjectModel;

    #endregion

    /// <summary>
    /// The Study class of the Study definition entity module.
    /// </summary>
    public class Study
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="Study"/> class.
        /// </summary>
        public Study()
        {
            this.CreationDate = DateTime.Now;
            this.ModifiedDate = DateTime.Now;
            this.CompletionDate = DateTime.Now;
            this.IsLocked = false;
            this.Archivable = false;
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets a value indicating whether the study is archivable.
        /// </summary>
        /// <value>
        /// The boolean archivable value.
        /// </value>
        public bool Archivable { get; private set; }

        /// <summary>
        /// Gets the completion date of the study.
        /// </summary>
        /// <value>
        /// The completion date of the study.
        /// </value>
        public DateTime CompletionDate { get; private set; }

        /// <summary>
        /// Gets or sets the value indicating who created the study.
        /// </summary>
        /// <value>
        /// The individual who created the study.
        /// </value>
        public string CreatedBy { get; private set; }

        /// <summary>
        /// Gets the creation date of the study.
        /// </summary>
        /// <value>
        /// The creation date of the study.
        /// </value>
        public DateTime CreationDate { get; private set; }

        /// <summary>
        /// Gets or sets the name of the customer.
        /// </summary>
        /// <value>
        /// The name of the customer.
        /// </value>
        public string CustomerName { get; set; }

        /// <summary>
        /// Gets or sets the description of the study.
        /// </summary>
        /// <value>
        /// The description of the study.
        /// </value>
        public string Description { get; set; }

        /// <summary>
        /// Gets or sets the id of the study.
        /// </summary>
        /// <value>
        /// The id of the study.
        /// </value>
        public int Id { get; set; }

        /// <summary>
        /// Gets a value indicating whether the study is locked.
        /// </summary>
        /// <value>
        /// The boolean islocked value.
        /// </value>
        public bool IsLocked { get; private set; }

        /// <summary>
        /// Gets the value indicating who last modified the study.
        /// </summary>
        /// <value>
        /// The last individual who modified the study.
        /// </value>
        public string ModifiedBy { get; private set; }

        /// <summary>
        /// Gets the modification date of the study.
        /// </summary>
        /// <value>
        /// The modification date of the study.
        /// </value>
        public DateTime ModifiedDate { get; private set; }

        /// <summary>
        /// Gets or sets the VPL reference number of the study.
        /// </summary>
        /// <value>
        /// The VPL reference number of the study.
        /// </value>
        public string Reference { get; set; }

        /// <summary>
        /// Gets or sets the title of the study.
        /// </summary>
        /// <value>
        /// The title of the study.
        /// </value>
        public string Title { get; set; }

        /// <summary>
        /// Gets or sets the treatments.
        /// </summary>
        /// <value>
        /// The treatments.
        /// </value>
        public Collection<Treatment> Treatments { get; set; }

        #endregion

        #region Public Methods

        /// <summary>
        /// Adds the treatment.
        /// </summary>
        /// <param name="treatment">
        /// The treatment.
        /// </param>
        public void AddTreatment(Treatment treatment)
        {
            if (this.Treatments.Contains(treatment))
            {
                return;
            }

            this.Treatments.Add(treatment);
        }

        /// <summary>
        /// Archives the study.
        /// </summary>
        public void ArchiveStudy()
        {
            this.CompletionDate = DateTime.Now;
            this.Archivable = true;
        }

        /// <summary>
        /// Locks the study.
        /// </summary>
        public void LockStudy()
        {
            this.IsLocked = true;
        }

        /// <summary>
        /// Uns the lock study.
        /// </summary>
        public void UnLockStudy()
        {
            this.IsLocked = false;
        }

        /// <summary>
        /// Updates the modified date.
        /// </summary>
        public void UpdateModifiedDate()
        {
            this.ModifiedDate = DateTime.Now;
        }

        #endregion
    }
}
